package com.sz.mes.excel.model;

import java.util.Date;
import java.lang.Double;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.HeadStyle;
import com.alibaba.excel.enums.poi.FillPatternTypeEnum;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.diboot.core.util.D;
import com.diboot.core.util.V;
import com.diboot.file.excel.BaseExcelModel;
import com.diboot.file.excel.annotation.ExcelBindDict;
import com.diboot.file.excel.annotation.ExcelBindField;
import com.diboot.file.excel.annotation.ExcelOption;
import com.fasterxml.jackson.annotation.JsonFormat;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;

import com.sz.mes.entity.Goods;

/**
 * 商品 导入model定义
 *
 * @author hem
 * @version 1.0
 * @date 2023-12-22
 * Copyright © szhs
 */
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@ExcelIgnoreUnannotated
@HeadStyle(fillPatternType = FillPatternTypeEnum.SOLID_FOREGROUND, fillForegroundColor = 1)
public class GoodsImportModel extends BaseExcelModel {

    /**
     * 料号
     */
    @Length(max = 100, message = "料号长度应小于100")
    @ExcelProperty(value = "料号")
    private String goodsCode;
    /**
     * 品名
     */
    @Length(max = 100, message = "品名长度应小于100")
    @ExcelProperty(value = "品名")
    private String goodsName;
    /**
     * 规格
     */
    @Length(max = 1000, message = "规格长度应小于1000")
    @ExcelProperty(value = "规格")
    private String specifications;
    /**
     * 单位
     */
    @Length(max = 100, message = "单位长度应小于100")
    @ExcelProperty(value = "单位")
    private String unit;
    /**
     * 存储编码
     */
    @Length(max = 100, message = "存储编码长度应小于100")
    @ExcelProperty(value = "存储编码")
    private String saveCode;
    /**
     * 存储地点
     */
    @Length(max = 100, message = "存储地点长度应小于100")
    @ExcelProperty(value = "存储地点")
    private String saveLocation;
    /**
     * 财务分类编码
     */
    @Length(max = 100, message = "财务分类编码长度应小于100")
    @ExcelProperty(value = "财务分类编码")
    private String financiaCode;
    /**
     * 财务分类名称
     */
    @Length(max = 100, message = "财务分类名称长度应小于100")
    @ExcelProperty(value = "财务分类名称")
    private String financialName;
    /**
     * 形态属性
     */
    @Length(max = 100, message = "形态属性长度应小于100")
    @ExcelProperty(value = "形态属性")
    private String shapeType;
    /**
     * 生产部门编码
     */
    @Length(max = 100, message = "生产部门编码长度应小于100")
    @ExcelProperty(value = "生产部门编码")
    private String productCode;
    /**
     * 生产部门名称
     */
    @Length(max = 100, message = "生产部门名称长度应小于100")
    @ExcelProperty(value = "生产部门名称")
    private String productGroupName;

    /**
     * 创建人
     */
//    @TableField(fill = FieldFill.INSERT)
    @ExcelProperty(value = "创建人")
    private String createBy;
//    /**
//     * 生产任务编号
//     */
//    @ExcelProperty(value = "生产任务编号")
//    private Long productTaskId;
//    /**
//     * excel内容
//     */
//    @ExcelProperty(value = "excel内容")
//    private String excelData;

    // 重写equals和hashCode方法，以便在过滤时能够正确地比较对象
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        GoodsImportModel goodsImportModel = (GoodsImportModel) o;
        Boolean goodsCodeSame = true;
        Boolean goodsNameSame = true;
        Boolean specificationsSame = true;
        Boolean unitSame = true;
        Boolean saveCodeSame = true;
        Boolean saveLocationSame = true;
        Boolean financiaCodeSame = true;
        Boolean financialNameSame = true;
        Boolean shapeTypeSame = true;
        Boolean productCodeSame = true;
        Boolean productGroupNameSame = true;
        Boolean createBySame = true;
        if (goodsCode != null) {
            goodsCodeSame = goodsCode.equals(goodsImportModel.goodsCode);
        }
        if (goodsName != null) {
            goodsNameSame = goodsName.equals(goodsImportModel.goodsName);
        }
        if (specifications != null) {
            specificationsSame = specifications.equals(goodsImportModel.specifications);
        }
        if (unit != null) {
            unitSame = unit.equals(goodsImportModel.unit);
        }
        if (saveCode != null) {
            saveCodeSame = saveCode.equals(goodsImportModel.saveCode);
        }
        if (saveLocation != null) {
            saveLocationSame = saveLocation.equals(goodsImportModel.saveLocation);
        }
        if (financiaCode != null) {
            financiaCodeSame = financiaCode.equals(goodsImportModel.financiaCode);
        }
        if (financialName != null) {
            financialNameSame = financialName.equals(goodsImportModel.financialName);
        }
        if (shapeType != null) {
            shapeTypeSame = shapeType.equals(goodsImportModel.shapeType);
        }
        if (productCode != null) {
            productCodeSame = productCode.equals(goodsImportModel.productCode);
        }
        if (productGroupName != null) {
            productGroupNameSame = productGroupName.equals(goodsImportModel.productGroupName);
        }
        if (createBy != null) {
            createBySame = createBy.equals(goodsImportModel.createBy);
        }

        return goodsCodeSame && goodsNameSame && specificationsSame && unitSame && saveCodeSame && saveLocationSame &&
                financiaCodeSame && financialNameSame && shapeTypeSame && productCodeSame && productGroupNameSame &&
                createBySame;
    }


    @Override
    public int hashCode() {
        return Objects.hash(goodsCode, goodsName, specifications, unit, saveCode, saveLocation, financiaCode,
                financialName, shapeType, productCode, productGroupName, createBy);
    }
}
